<!DOCTYPE html>
<html>
	{include file="public1/_header" /}
	<!-- 配置文件 -->
	<script type="text/javascript" src="__STATIC__/static/ueditor/ueditor.config.js"></script>
	<!-- 编辑器源码文件 -->
	<script type="text/javascript" src="__STATIC__/static/ueditor/ueditor.all.js"></script>
	<body style="background: #fff;">
		<div>
			<div class="layui-row">
				<div class="layui-col-md12">
					<form class="layui-form" action="">
						<div class="layui-card">
							<div class="layui-card-body" style="overflow: hidden;">
								<div class="layui-col-md12" style="padding-bottom: 65px;">
									<table class="layui-table table-form">
										<colgroup>
											<col width="100">
											<col>
										</colgroup>
										<tbody>
											<tr>
												<th>标题 <span style='color:red'>*</span></th>
												<td>
													<input lay-reqText="标题必须填写" type="text" name="title" required lay-verify="required" autocomplete="off"
													 class="layui-input title">
												</td>
											</tr>

											<tr>
												<th>截止日期: <span style='color:red'>*</span></th>
												<td><input lay-reqText="开机时间必须选择" type="text" readonly="" id="start_time" name="closing_date" required
													 lay-verify="required" placeholder="" autocomplete="off" class="layui-input"></td>
											</tr>
											<tr>
												<th>活动时间段 <span style='color:red'>*</span></th>
												<td>
													<input lay-reqText="关机时间必须选择" type="text" readonly="" id="end_time" name="time_slot" required lay-verify="required"
													 placeholder="" autocomplete="off" class="layui-input">
												</td>
											</tr>

											<tr>
												<th>排序</th>
												<td>
													<input type="number" value="100" name="sort" required lay-verify="required" autocomplete="off" class="layui-input">
												</td>
											</tr>
										</tbody>
									</table>
								</div>

								<div style="text-align: center;" class="layui-layout-admin">
									<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
									<button type="button" id="close" class="layui-btn layui-btn-primary">放弃</button>
								</div>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript">
		$(function() {
			layui.use(['form', 'util', 'laydate'], function() {
				var form = layui.form;
				var $ = layui.jquery;
				var laydate = layui.laydate;
				var util = layui.util;

				laydate.render({
					elem: '#start_time',
					type: 'datetime',
					format: 'yyyy-MM-dd HH:mm:ss'
				});
				laydate.render({
					elem: '#end_time',
					type: 'datetime',
					range: '~',
					format: 'yyyy-MM-dd HH:mm:ss'
				});
				//监听提交
				form.on('submit(formDemo)', function(obj) {
					var index = parent.layer.getFrameIndex(window.name);
					var lfc = top.layerFrameConfig;
					var info = lfc.iframeB.info;

					$.post("{:url('add')}", obj.field, function(res) {
						if (res.status == 1) {
							layer.msg('添加成功', {
								icon: 1,
								time: 300
							}, function() {
								parent.layer.close(index); //再执行关闭
								info.reload()
							});

						} else {
							layer.msg(res.message)
						}
					})
					return false;
				});

				$("#close").click(function() {
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);
				})

			});


		})
	</script>
</html>
